<?php
//
//	file: includes/aucp/class_groups.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 29 $
//	$Date: 2008-07-19 15:59:35 +0000 (Sat, 19 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: simple group caching

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

// login or install
if ( defined('IN_LOGIN') || defined('IN_INSTALL') )
{
	return;
}

//class
class group_handler
{
	var $data = array();
	var $data_time;
	var $from_cache;

	function read($force=false)
	{
		global $config;

		$db_cached = new cache('dta_groups', $config->data['cache_path'], $config->data['cache_disabled_groups']);
		$sql = 'SELECT *
				FROM ' . GROUPS_TABLE . '
				WHERE group_single_user <> ' . true . '
				ORDER BY group_weight ASC';
		$this->data = $db_cached->sql_query($sql, __LINE__, __FILE__, $force);
		$this->data_time = $db_cached->data_time;
		$this->from_cache = $db_cached->from_cache;

		return true;
	}

	function list_groups()
	{
		$array = array();
		foreach ($this->data as $group)
		{
			$array[] = $group['group_id'];
		}

		return $array;
	}
}

// cache
class group_cache extends plug_ins
{
	function start()
	{
		global $cache_table_list;

		$cache_table_list['groups'] = 'group_handler';

		return;
	}
}

// plugs
$config->set_plug_ins('mod_aucp_groups', array(
	'caches' => array(
		'object' => 'groups_cache',
	),
));

$groups_list = new group_handler();
$groups_list->read();

?>